<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>FileUtil</title>
</head>
<body>
<input type="file" id="input">
<script src="../../../lib/baitu.min.js"></script>
<script>
    const {FileUtil} = Baitu;
    console.log(FileUtil.getMainName("aa.exe"))
    console.log(FileUtil.getTypeSimple("aa.exe"))
    console.log(FileUtil.isTypeSimple("aa.png", "png"))
    console.log(FileUtil.isTypeSimple("aa.png", "jpg"))

    const input = document.querySelector("#input");
    input.onchange = async () => {
        const file = input.files[0];
        if (file) {
            try {
                console.log(FileUtil.getFileTypeSimple(file))
                console.log(FileUtil.isFileTypeSimple(file, "png"))
                FileUtil.getHexString(file, 100).then(res => console.log(res))
                FileUtil.getArrayBuffer(file, 100).then(res => console.log(res))
                FileUtil.getUint8Array(file, 100).then(res => console.log(res))
                FileUtil.getTypeMagic(file, 100).then(res => console.log(res))
                FileUtil.isTypeMagic(file, "png").then(res => console.log(res))
                FileUtil.toImage(file).then(res => console.log(res)).catch(e => console.log(e))
                FileUtil.getMD5(file).then(res => console.log(res))
            } catch (error) {
                console.error('Error reading file:', error);
            }
        }
    };
</script>
</body>
</html>
